Fix sort order of function keys
authorjustbur <justin@burkett.cc>
Fri, 13 Nov 2015 17:03:26 +0000 (12:03 -0500)
committerjustbur <justin@burkett.cc>
Fri, 13 Nov 2015 17:03:26 +0000 (12:03 -0500)
which-key.el

index 7025fc5dc46e9431c26f9fbca36d8040bd7f5f38..caf1744c8b92d5a105329e6a2200b17f1f8390db 100644 (file)
@@ -972,18 +972,23 @@ width) in lines and characters respectively."
          (bsp? (string-match-p srgxp b))
          (prrgxp "^\\(M\\|C\\|S\\|A\\|H\\|s\\)-")
          (apr? (string-match-p prrgxp a))
-         (bpr? (string-match-p prrgxp b)))
+         (bpr? (string-match-p prrgxp b))
+         (afn? (string-match-p "<f[0-9]+>" a))
+         (bfn? (string-match-p "<f[0-9]+>" b)))
     (cond ((or aem? bem?) (and aem? (not bem?)))
           ((and asp? bsp?)
            (if (string-equal (substring a 0 3) (substring b 0 3))
-               (which-key--key-description< (substring a 3) (substring b 3))
+               (which-key--key-description-alpha< (substring a 3) (substring b 3))
              (string-lessp a b)))
           ((or asp? bsp?) asp?)
           ((and a1? b1?) (which-key--alpha< a b))
           ((or a1? b1?) a1?)
+          ((and afn? bfn?)
+           (< (string-to-number (replace-regexp-in-string "<f\\([0-9]+\\)>" "\\1" a))
+              (string-to-number (replace-regexp-in-string "<f\\([0-9]+\\)>" "\\1" b))))
           ((and apr? bpr?)
            (if (string-equal (substring a 0 2) (substring b 0 2))
-               (which-key--key-description< (substring a 2) (substring b 2))
+               (which-key--key-description-alpha< (substring a 2) (substring b 2))
              (string-lessp a b)))
           ((or apr? bpr?) apr?)
           (t (string-lessp a b)))))
@@ -1009,7 +1014,9 @@ before upper."
          (bsp? (string-match-p srgxp b))
          (prrgxp "^\\(M\\|C\\|S\\|A\\|H\\|s\\)-")
          (apr? (string-match-p prrgxp a))
-         (bpr? (string-match-p prrgxp b)))
+         (bpr? (string-match-p prrgxp b))
+         (afn? (string-match-p "<f[0-9]+>" a))
+         (bfn? (string-match-p "<f[0-9]+>" b)))
     (cond ((or aem? bem?) (and aem? (not bem?)))
           ((and asp? bsp?)
            (if (string-equal (substring a 0 3) (substring b 0 3))
@@ -1018,6 +1025,9 @@ before upper."
           ((or asp? bsp?) asp?)
           ((and a1? b1?) (string-lessp a b))
           ((or a1? b1?) a1?)
+          ((and afn? bfn?)
+           (< (string-to-number (replace-regexp-in-string "<f\\([0-9]+\\)>" "\\1" a))
+              (string-to-number (replace-regexp-in-string "<f\\([0-9]+\\)>" "\\1" b))))
           ((and apr? bpr?)
            (if (string-equal (substring a 0 2) (substring b 0 2))
                (which-key--key-description< (substring a 2) (substring b 2))